import java.io.IOException;
import java.net.*;
import java.time.LocalDateTime;

public class UdpExp01 {
    public static void main(String[] args) {
        DatagramSocket ds = null;
        try {
            ds = new DatagramSocket(3006);
            while(true){
                String str0 = "Dezhou,Shandong Province. 现在时间："+LocalDateTime.now();
                byte[] strBy = str0.getBytes();
                DatagramPacket dp = new DatagramPacket(strBy, strBy.length, InetAddress.getByName("10.100.96.14"), 8954);
                System.out.println("发送成功！");
                Thread.sleep(1000);
                ds.send(dp);
            }
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            ds.close();
        }
    }
}
